"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//1、ts中类的定义
var Person = /** @class */ (function () {
    function Person(n) {
        this.name = n;
    }
    Person.prototype.run = function () {
        alert(this.name);
    };
    Person.prototype.getName = function () {
        return this.name;
    };
    Person.prototype.setName = function (name) {
        this.name = name;
    };
    return Person;
}());
var p = new Person("张三");
p.run();
p.setName("李四");
alert(p.getName());
//2、ts中实现继承     extends、super
var Person1 = /** @class */ (function () {
    function Person1(name) {
        this.name = name;
    }
    Person1.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    return Person1;
}());
var p1 = new Person('王五');
p1.run();
alert(p1.run());
var Web = /** @class */ (function (_super) {
    __extends(Web, _super);
    function Web(name) {
        return _super.call(this, name) || this;
    }
    return Web;
}(Person1));
var w = new Web("李四");
w.run();
//3、ts中继承的探讨    父类的方法和子类的方法一致
var Person2 = /** @class */ (function () {
    function Person2(name) {
        this.name = name;
    }
    Person2.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    return Person2;
}());
var p2 = new Person('王五');
p2.run();
alert(p2.run());
var Web2 = /** @class */ (function (_super) {
    __extends(Web2, _super);
    function Web2(name) {
        return _super.call(this, name) || this;
    }
    Web2.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8-\u5B50\u7C7B";
    };
    Web2.prototype.work = function () {
        alert(this.name + "\u5728\u5DE5\u4F5C");
    };
    return Web2;
}(Person2));
var w2 = new Web2("李四");
alert(w2.run());
alert(w2.work());
//3、类里面的修饰符 typescript里面定义属性提供了三种修饰符
/**
 * public:公有，在类里面、子类、类外面都可以访问
 * protected:保护类型，在类里面、子类里面可以访问，在类外部没法访问
 * private:私有，在类里面可以访问，在子类和类外部都没法访问
 *
 * 属性不加修饰符，默认公有
 */
var Person3 = /** @class */ (function () {
    function Person3(name) {
        this.name = name;
    }
    Person3.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    return Person3;
}());
var Web3 = /** @class */ (function (_super) {
    __extends(Web3, _super);
    function Web3(name) {
        return _super.call(this, name) || this;
    }
    Web3.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8-\u5B50\u7C7B";
    };
    Web3.prototype.work = function () {
        alert(this.name + "\u5728\u5DE5\u4F5C-\u5B50\u7C7B");
    };
    return Web3;
}(Person));
var w3 = new Web3('李四');
w3.work();
//protected:保护类型    在类里面、子类里面可以访问，在类外部没法访问
var Person4 = /** @class */ (function () {
    function Person4(name) {
        this.name = name;
    }
    Person4.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    return Person4;
}());
var Web4 = /** @class */ (function (_super) {
    __extends(Web4, _super);
    function Web4(name) {
        return _super.call(this, name) || this;
    }
    Web4.prototype.work = function () {
        alert(this.name + "\u5728\u5DE5\u4F5C-\u5B50\u7C7B");
    };
    return Web4;
}(Person));
var w4 = new Web4('李四111');
alert(w4.work());
alert(w4.run());
//4、静态属性、静态方法
/*function Person5(){
    this.run1 = function (){

    }
}
Person5.name = '哈哈哈';//静态属性
Person5.run2 = function () {//静态方法

}
var p5 = new Person5();
Person5.run2();*/
//typescript
var Person5 = /** @class */ (function () {
    function Person5(name) {
        this.name = name;
    }
    Person5.prototype.run = function () {
        alert(this.name + "\u5728\u8FD0\u52A8");
    };
    Person5.prototype.work = function () {
        alert(this.name + "\u5728\u5DE5\u4F5C");
    };
    Person5.print = function () {
        alert('print方法');
    };
    return Person5;
}());
var p5 = new Person5('张三');
p5.run(); //调用实例方法
Person5.print(); //调用静态方法
//多态:父类定义一个方法不去实现，让继承它的子类去实现，每一个子类有不同的表现
//多态属于继承
var Animal = /** @class */ (function () {
    function Animal(name) {
        this.name = name;
    }
    Animal.prototype.eat = function () {
        console.log('吃的方法'); //具体吃什么不知道  具体吃什么继承它的子类去实现，每个子类表现不一样
    };
    return Animal;
}());
var Dog = /** @class */ (function (_super) {
    __extends(Dog, _super);
    function Dog(name) {
        return _super.call(this, name) || this;
    }
    Dog.prototype.eat = function () {
        return this.name + '吃肉';
    };
    return Dog;
}(Animal));
var Cat = /** @class */ (function (_super) {
    __extends(Cat, _super);
    function Cat(name) {
        return _super.call(this, name) || this;
    }
    Cat.prototype.eat = function () {
        return this.name + '吃鱼';
    };
    return Cat;
}(Animal));
//typescript中的抽象类:它是提供给其它类继承的基类，不能直接被实例化
//用abstract关键字定义抽象类和抽象方法，抽象类中的抽象方法不包含具体的实现，必须在派生类中实现
